package com.woniuxy.mapper;

import com.woniuxy.entity.PawnResource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zcx,ftl,gr,rhs
 * @since 2022-01-07
 */
public interface PawnResourceMapper extends BaseMapper<PawnResource> {
    @Select("SELECT\n" +
            "\tt4.resources_uri\n" +
            "FROM\n" +
            "\t`user_role` t1\n" +
            "JOIN role_menu t2 ON t1.role_id = t2.role_id\n" +
            "JOIN pawn_menus_resources t3 ON t2.menu_id = t3.menus_id\n" +
            "JOIN pawn_resource t4 ON t4.resources_id = t3.resources_id\n" +
            "WHERE t1.user_id=#{id}\n" +
            "UNION\n" +
            "\tSELECT\n" +
            "\t\tresources_uri\n" +
            "\tFROM\n" +
            "\t\tpawn_resource\n" +
            "\tWHERE\n" +
            "\t\tresources_state = 0")
    List<String> selectResourceByUserId(Integer id);
}
